<template>
  <div class="gonggao">
      <div>

          <el-input v-model="parmas.type" placeholder="类型" style="width: 200px;"></el-input>
          <el-input v-model="parmas.titleLike" placeholder="标题" style="width: 200px;"></el-input>
          <el-select v-model="parmas.isShow" placeholder="请选择">
              <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
          </el-select>
          <el-date-picker v-model="parmas.dateAddBeigin" type="date" placeholder="发布时间起">
          </el-date-picker>
          <el-date-picker v-model="parmas.dateAddEnd" type="date" placeholder="发布时间止">
          </el-date-picker>
          <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
          <el-button type="success">+添加</el-button>
      </div>
      <el-table :data="tableData" style="width: 100%">
          <el-table-column prop="title" label="标题">
          </el-table-column>
          <el-table-column label="状态">
              <template slot-scope="scope">
                  <div>
                      <el-button size="small" type="success" round style="border-radius: 3px;"> {{ scope
                          | fmtisShow }}</el-button>
                  </div>
              </template>
          </el-table-column>
          <el-table-column prop="dateAdd" label="添加内容/更新时间">
          </el-table-column>
          <el-table-column label="操作">
              <template slot-scope="scope">
                  <div>
                      <!-- {{ scope.row }} -->
                      <span @click="edit" style="color: blue;">编辑</span>
                      <span @click="del(scope.row)" style="color: red;">删除</span>
                  </div>
              </template>
          </el-table-column>
      </el-table>
  </div>
</template>
<script>
import { gonggao } from '@/api/gonggao.js';
export default {
  data() {
      return {
          options: [{
              value: true,
              label: '显示'
          }, {
              value: false,
              label: '隐藏'
          }],
          tableData: [],
          parmas: {
              type: "",
              titleLike: "",
              isShow: "",
              dateAddBeigin: "",
              dateAddEnd: ""
          },
      }
  },
  mounted() {
      this.getList()
  },
  methods: {
      async getList() {
          gonggao(this.parmas)
          console.log(this.tableData)
          let { data: res } = await gonggao(this.parmas)
          this.total = res.totalRow
          console.log(res);
          this.gonggao = this.options
          this.tableData = res.result
          this.gonggao = this.tableData
          console.log(this.parmas.isShow)
      },
      search() {
          console.log(this.parmas);
      },
      del(row) {
          console.log(row)
      },
      edit(row) {
          console.log(row);
      },
  },
  filters: {
      fmtisShow: function (val) {
          if (val) return "展示"
          else return "隐藏"
      }
  }
}


</script>
